Skip to content

Conversation

@bwebs
Copy link
Contributor

@bwebs bwebs commented Jul 1, 2025

…cies

  • Added new optional dependencies in pyproject.toml, including pydash and fastapi[standard].
  • Updated the README to reflect changes in optional dependencies and their usage.
  • Introduced a new test script to validate the functionality of UserAttributeUpdater with only base dependencies.
  • Refactored the CLI to handle missing optional dependencies gracefully, providing informative error messages.
  • Improved logging configuration to ensure compatibility with missing libraries.

…cies

- Added new optional dependencies in `pyproject.toml`, including `pydash` and `fastapi[standard]`.
- Updated the README to reflect changes in optional dependencies and their usage.
- Introduced a new test script to validate the functionality of `UserAttributeUpdater` with only base dependencies.
- Refactored the CLI to handle missing optional dependencies gracefully, providing informative error messages.
- Improved logging configuration to ensure compatibility with missing libraries.
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @bwebs, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the project's dependency management strategy by making more components optional, thereby reducing the default installation size. It enhances the user experience by providing graceful error handling for CLI commands when optional dependencies are missing and ensures core features remain functional with minimal installations. Additionally, it refines logging to be more resilient and updates documentation to reflect these changes.

Highlights

  • Refactored Dependency Management: Moved several core CLI dependencies (like typer, rich, structlog, questionary, requests, cryptography) from base dependencies to a new cli optional dependency group in pyproject.toml. This reduces the base installation footprint and allows users to install only the components they need.
  • Graceful CLI Degradation: Implemented dynamic loading for optional CLI command groups (mcp, observability, tools). If a user attempts to run a command whose required optional dependencies are not installed, the CLI will now provide an informative error message and suggest installing the relevant extra, rather than crashing.
  • Enhanced Logging Robustness: Updated logging configurations to conditionally import and use structlog and rich components. This ensures the application's logging system remains functional even if these optional libraries are not present, preventing ModuleNotFoundError exceptions.
  • Updated Documentation: The README.md has been revised to reflect the new optional dependency structure, including renaming embed-observability to observability and user-attribute-updater to tools, and simplifying the descriptions of available extras.
  • Validated Base Functionality: Introduced a new test script and a dedicated test case to verify that core functionalities, specifically the UserAttributeUpdater, can be imported and used successfully when only the project's base dependencies are installed, without any optional extras.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request effectively refactors dependency management by introducing optional dependencies and updating the CLI to handle missing libraries gracefully. The logging configuration has also been improved for compatibility. However, there are a few areas that require attention regarding dependency consistency and test correctness.

Comment on lines +42 to +43
if not structured_logger:
raise Exception("Structured logger is not available")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The structured_logger is part of the cli optional dependency, not the observability extra. This check introduces a hard dependency on structlog for the observability module, which contradicts the goal of handling missing optional dependencies gracefully. If structured_logger is truly required for this module, it should be explicitly listed as a dependency for the observability extra in pyproject.toml. Otherwise, consider falling back to the base logger or handling its absence more gracefully to prevent a hard crash.

if not structured_logger:
    # Fallback to base logger or handle gracefully if structlog is truly optional
    # For now, raising an exception as it's a critical component for this module.
    raise Exception("Structured logger is not available")

Comment on lines +227 to +228
assert '"value":"test"' not in output
assert '"update_type":"default"' in output
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The assertion assert '"value":"test"' not in output appears to be incorrect. The UserAttributeUpdater class (from lkr/tools/classes.py) defines value as a standard field. By default, model_dump_json() should include all fields, so value is expected to be present in the JSON output. This assertion will likely cause the test to fail if model_dump_json() behaves as expected. Please verify if value is indeed intended to be excluded from the JSON output, and if so, adjust the UserAttributeUpdater's Pydantic configuration (e.g., using Field(exclude=True)) or modify the test assertion.

Suggested change
assert '"value":"test"' not in output
assert '"update_type":"default"' in output
assert '"user_attribute":"test"' in output
assert '"value":"test"' in output
assert '"update_type":"default"' in output

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is correct, value is listed as exclude

lkr/main.py Outdated
Comment on lines 38 to 40
logger.error(msg)
logger.error(import_error)
raise typer.Exit(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

When an error occurs, it's best practice to exit with a non-zero status code (e.g., typer.Exit(1)) to indicate failure. Exiting with 0 typically signifies successful execution, which might be misleading for a command that failed to load due to missing dependencies.

Suggested change
logger.error(msg)
logger.error(import_error)
raise typer.Exit(0)
logger.error(msg)
logger.error(import_error)
raise typer.Exit(1)

@bwebs bwebs merged commit 2a1f1c3 into main Jul 1, 2025
1 check passed
@bwebs bwebs deleted the bryan/lazy-loading branch July 1, 2025 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants